package tasks.leetcode;

public class TaskIsPalindrome {

    public static void main(String[] args) {
        boolean palindrome = new TaskIsPalindrome().isPalindrome(131);
        System.out.println(palindrome);
    }

    public boolean isPalindrome(int x) {
        if (x <= 0 || (x % 10 == 0 && x != 0)) {
            return false;
        }
        int revertNum = 0;
        while (revertNum < x) {
            revertNum = 10 * revertNum + x % 10;
            x = x / 10;
        }
        return x == revertNum || x==revertNum/10;
    }
}
